//
//  NSArray+Helper.m
//  crowd
//
//  Created by 王春程 on 16/4/28.
//  Copyright © 2016年 caocaod.com. All rights reserved.
//

#import "NSArray+Helper.h"

@implementation NSArray (Helper)

+ (NSArray *)arrayPraseWithString {
    if(!UserValue(@"cookie")) {
        return nil;
    }
    NSMutableArray *muArr = [NSMutableArray array];
    NSDictionary *dic = (NSDictionary *)UserValue(@"cookie");
    NSString *keyString = dic[@"name"];
    NSString *token = dic[@"token"];
    [muArr addObject:keyString];
    [muArr addObject:token];
    return muArr;
}

//带历史订单的返回
+ (NSArray *)arrayPraseWithOrderArray:(NSArray *)indexArr {
    BOOL flag = YES;
    
    NSArray *nameArr = @[@"收派员",@"集结点",@"支线",@"BD",@"历史订单",@"个人资料",@"扫一扫",@"转运"];
    NSMutableArray *returnArray = [NSMutableArray array];
    for(NSString *indexString in indexArr) {
        if([indexString integerValue] >= 4) {
            flag = NO;
        }
    }
    
    if(indexArr && indexArr.count != 0 && flag) {
        for(NSInteger i = 0 ; i < indexArr.count ; i ++) {
            NSString *index = indexArr[i];
            NSInteger sharedIndex = [index integerValue];
            NSString *nameString = nameArr[sharedIndex];
            [returnArray addObject:nameString];
        }
    }

    [returnArray addObject:@"历史订单"];
    [returnArray addObject:@"个人资料"];
    [returnArray addObject:@"扫一扫"];
    [returnArray addObject:@"转运"];
    return returnArray;
}
@end
